import { defineStore } from 'pinia';
import imageUrl1 from '@/assets/message/1.png'
import imageUrl2 from '@/assets/message/2.png'
import imageUrl3 from '@/assets/message/3.png'
import imageUrl4 from '@/assets/message/4.png'
import imageUrl5 from '@/assets/message/5.png'
import imageUrl6 from '@/assets/message/6.png'
import imageUrl7 from '@/assets/message/7.png'
import imageUrl8 from '@/assets/message/8.png'
import imageUrl9 from '@/assets/message/9.png'
import imageUrl10 from '@/assets/message/10.png'
import imageUrl11 from '@/assets/message/11.png'
import imageUrl12 from '@/assets/message/12.png'
import imageUrl13 from '@/assets/message/13.png'
import type { FriendItem } from '@/types/friends'
import { ref } from 'vue';
export const useFriendStore = defineStore('friend', () => {
    const _friends: FriendItem[] = [
        {
            id: 1,
            imgUrl: imageUrl1,
            tip: 2,
            name: '风继续吹',
            time: '7/23 23:22',
            news: '你好，最近怎么样？'
        },
        {
            id: 2,
            imgUrl: imageUrl2,
            tip: 33,
            name: '陈奕迅',
            time: '7/23 15:32',
            news: '记得今晚一起吃晚饭。'
        },
        {
            id: 3,
            imgUrl: imageUrl3,
            tip: 66,
            name: '周杰伦',
            time: '7/23 10:52',
            news: '我在机场了，你那边情况如何？'
        },
        {
            id: 4,
            imgUrl: imageUrl4,
            tip: 43,
            name: '张国荣',
            time: '7/21 09:22',
            news: '关于明天的会议，你准备好了吗？'
        },
        {
            id: 5,
            imgUrl: imageUrl5,
            tip: 43,
            name: '陈慧娴',
            time: '7/28 03:22',
            news: '关于明天的会议，你准备好了吗？'
        },
        {
            id: 6,
            imgUrl: imageUrl6,
            tip: 43,
            name: '张学友',
            time: '7/13 22:22',
            news: '关于明天的会议，你准备好了吗？'
        }
        ,
        {
            id: 7,
            imgUrl: imageUrl7,
            tip: 43,
            name: '杨千嬅',
            time: '7/25 14:22',
            news: '关于明天的会议，你准备好了吗？'
        },
        {
            id: 8,
            imgUrl: imageUrl8,
            tip: 43,
            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        },
        {
            id: 9,
            imgUrl: imageUrl9,
            tip: 43,
            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        },
        {
            id: 10,
            imgUrl: imageUrl10,
            tip: 53,
            name: '周兴哲',
            time: '7/16 10:34',
            news: '项目进展顺利，猛猛学。'
        },
        {
            id: 11,
            imgUrl: imageUrl11,
            tip: 43,
            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        },
        {
            id: 12,
            imgUrl: imageUrl12,
            tip: 43,
            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        },
        {
            id: 13,
            imgUrl: imageUrl13,
            tip: 43,
            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        },
        {

            id: 14,

            imgUrl: imageUrl1,

            tip: 2,

            name: '风继续吹',

            time: '7/23 23:22',

            news: '你好，最近怎么样？'

        },

        {

            id: 15,

            imgUrl: imageUrl2,

            tip: 33,

            name: '陈奕迅',

            time: '7/23 15:32',

            news: '记得今晚一起吃晚饭。'

        },

        {

            id: 16,

            imgUrl: imageUrl3,

            tip: 66,

            name: '周杰伦',

            time: '7/23 10:52',

            news: '我在机场了，你那边情况如何？'

        },

        {

            id: 17,

            imgUrl: imageUrl5,

            tip: 43,

            name: '张国荣',

            time: '7/21 09:22',

            news: '关于明天的会议，你准备好了吗？'

        },

        {

            id: 18,

            imgUrl: imageUrl5,

            tip: 43,

            name: '陈慧娴',

            time: '7/28 03:22',

            news: '关于明天的会议，你准备好了吗？'

        },

        {

            id: 19,

            imgUrl: imageUrl6,

            tip: 43,

            name: '张学友',

            time: '7/13 22:22',

            news: '关于明天的会议，你准备好了吗？'

        }

        ,

        {

            id: 20,

            imgUrl: imageUrl7,

            tip: 43,

            name: '杨千嬅',

            time: '7/25 14:22',

            news: '关于明天的会议，你准备好了吗？'

        },

        {

            id: 21,

            imgUrl: imageUrl8,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        },

        {

            id: 22,

            imgUrl: imageUrl9,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        },

        {

            id: 23,

            imgUrl: imageUrl11,

            tip: 53,

            name: '周兴哲',

            time: '7/16 10:34',

            news: '项目进展顺利，猛猛学。'

        },
        {

            id: 24,

            imgUrl: imageUrl12,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        },

        {

            id: 25,

            imgUrl: imageUrl13,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        },

        {

            id: 26,

            imgUrl: imageUrl1,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        }, {

            id: 27,

            imgUrl: imageUrl2,

            tip: 2,

            name: '风继续吹',

            time: '7/23 23:22',

            news: '你好，最近怎么样？'

        },

        {

            id: 28,

            imgUrl: imageUrl3,

            tip: 33,

            name: '陈奕迅',

            time: '7/23 15:32',

            news: '记得今晚一起吃晚饭。'

        },

        {

            id: 29,

            imgUrl: imageUrl4,

            tip: 66,

            name: '周杰伦',

            time: '7/23 10:52',

            news: '我在机场了，你那边情况如何？'

        },

        {

            id: 30,

            imgUrl: imageUrl5,

            tip: 43,

            name: '张国荣',

            time: '7/21 09:22',

            news: '关于明天的会议，你准备好了吗？'

        },

        {

            id: 31,

            imgUrl: imageUrl6,

            tip: 43,

            name: '陈慧娴',

            time: '7/28 03:22',

            news: '关于明天的会议，你准备好了吗？'

        },

        {

            id: 32,

            imgUrl: imageUrl7,

            tip: 43,

            name: '张学友',

            time: '7/13 22:22',

            news: '关于明天的会议，你准备好了吗？'

        }

        ,

        {

            id: 33,

            imgUrl: imageUrl8,

            tip: 43,

            name: '杨千嬅',

            time: '7/25 14:22',

            news: '关于明天的会议，你准备好了吗？'

        },

        {

            id: 34,

            imgUrl: imageUrl9,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        },

        {

            id: 35,

            imgUrl: imageUrl10,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        },
        {

            id: 36,

            imgUrl: imageUrl11,

            tip: 53,

            name: '周兴哲',

            time: '7/16 10:34',

            news: '项目进展顺利，猛猛学。'


        },

        {

            id: 37,

            imgUrl: imageUrl12,

            tip: 43,

            name: '林俊杰',

            time: '7/16 10:34',

            news: '项目进展顺利，感谢你的努力。'

        },

        {

            id: 38,

            imgUrl: imageUrl13,

            tip: 43,

            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        },
        {
            id: 39,
            imgUrl: imageUrl1,
            tip: 43,
            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        },
        {
            id: 40,
            imgUrl: imageUrl2,
            tip: 43,
            name: '林俊杰',
            time: '7/16 10:34',
            news: '项目进展顺利，感谢你的努力。'
        }
    ]

    const friends = ref<FriendItem[]>([])

    // 模拟异步请求
    const getFriendList = (page: number, size: number) => {
        return new Promise<{
            data: FriendItem[]
            page: number
            total: number
            hasMore: boolean
        }>((resolve) => {
            setTimeout(() => {
                const data = _friends.slice((page - 1) * size, page * size)
                friends.value = [...friends.value, ...data]
                resolve({
                    data,
                    page,
                    total: _friends.length,
                    hasMore: page * size < _friends.length,
                })
            }, 100)
        })
    }
    return {
        friends,
        getFriendList
    }
});